/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package opk.Solver;

import java.awt.Point;
import java.util.ArrayList;
import java.util.HashMap;
import opk.Generator.Edge;

/**
 *
 * @author Dawid
 */
public class GraphPoint extends Point implements Comparable<GraphPoint>
{

    private ArrayList<GraphPoint> pointsICanSee;
    private HashMap<GraphPoint,  java.lang.Double> distanceToPoints;
    private HashMap<GraphPoint, ArrayList<Edge>> routesToPoints;

    private ArrayList<Edge> currentlyShortestRoute;
    private java.lang.Double currentlyShortestRouteLength;
    private boolean wasVisited;

    public GraphPoint(Point point)
    {
        super(point);
        this.pointsICanSee = new ArrayList<GraphPoint>();
        this.distanceToPoints = new HashMap<GraphPoint, java.lang.Double>();
        this.routesToPoints = new HashMap<GraphPoint, ArrayList<Edge>>();
        this.currentlyShortestRoute = new ArrayList<Edge>();
        this.currentlyShortestRouteLength = java.lang.Double.MAX_VALUE;
        
        this.wasVisited = false;
    }

    public GraphPoint(Point point, GraphPoint graphPointToAdd)
    {
        super(point);
        this.pointsICanSee = new ArrayList<GraphPoint>();
        this.pointsICanSee.add(graphPointToAdd);
        
        this.distanceToPoints = new HashMap<GraphPoint, java.lang.Double>();
        this.routesToPoints = new HashMap<GraphPoint, ArrayList<Edge>>();
        this.currentlyShortestRoute = new ArrayList<Edge>();
        this.currentlyShortestRouteLength = java.lang.Double.MAX_VALUE;

        this.wasVisited = false;
    }

    public void addPointICanSee(GraphPoint graphPoint)
    {
        pointsICanSee.add(graphPoint);
    }

    /**
     * @return the pointsICanSee
     */
    public ArrayList<GraphPoint> getPointsICanSee()
    {
        return pointsICanSee;
    }

    public void setDistance(GraphPoint graphPoint, java.lang.Double distance)
    {
        getDistanceToPoints().put(graphPoint, new java.lang.Double(distance));
    }


    /**
     * @return the distanceToPoints
     */
    public HashMap<GraphPoint, java.lang.Double> getDistanceToPoints()
    {
        return distanceToPoints;
    }

    /**
     * @param distanceToPoints the distanceToPoints to set
     */
    public void setDistancesToPoints(HashMap<GraphPoint, java.lang.Double> distanceToPoints)
    {
        this.distanceToPoints = distanceToPoints;
    }

    /**
     * @param currentlyShourtestRoute the currentlyShourtestRoute to set
     */
    public void setCurrentlyShourtestRoute(ArrayList<Edge> currentlyShourtestRoute)
    {
        ArrayList<Edge> newShortestRoute = (ArrayList<Edge>) currentlyShourtestRoute.clone();
        this.currentlyShortestRoute = newShortestRoute;
    }

    public void clearCurrentlyShourtestRoute()
    {
        this.currentlyShortestRoute.clear();
    }

    /**
     * @return the currentlyShortestRouteLength
     */
    public java.lang.Double getCurrentlyShortestRouteLength()
    {
       
        return currentlyShortestRouteLength;

        //return currentlyShortestRouteLength;
    }

    /**
     * @param currentlyShortestRouteLength the currentlyShortestRouteLength to set
     */
    public void setCurrentlyShortestRouteLength(java.lang.Double currentlyShortestRouteLength)
    {
        this.currentlyShortestRouteLength = new java.lang.Double(currentlyShortestRouteLength);
    }

    /**
     * @return the wasVisited
     */
    public boolean isVisited()
    {
        return wasVisited;
    }

    /**
     * @param wasVisited the wasVisited to set
     */
    public void setWasVisited(boolean wasVisited)
    {
        this.wasVisited = wasVisited;
    }

    public void setRoute(GraphPoint graphPoint, ArrayList<Edge> routeToPoints)
    {
        this.routesToPoints.put(graphPoint, routeToPoints);
    }

    /**
     * @return the routesToPoints
     */
    public HashMap<GraphPoint, ArrayList<Edge>> getRoutesToPoints()
    {
        return routesToPoints;
    }

    /**
     * @param routesToPoints the routesToPoints to set
     */
    public void setRoutesToPoints(HashMap<GraphPoint, ArrayList<Edge>> routesToPoints)
    {
        this.routesToPoints = routesToPoints;
    }

    /**
     * @return the currentlyShortestRoute
     */
    public ArrayList<Edge> getCurrentlyShortestRoute()
    {
        return currentlyShortestRoute;
    }

    public int compareTo(GraphPoint o)
    {

        if (o.y > this.y)
        {
            return 1;
        }
        else if (o.y == this.y)
        {
            if (o.x > this.x)
            {
                return 1;
            }
            else if (o.x == this.x)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }
        else
        {
            return -1;
        }
    }

    



}
